package com.sjtu.web.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.sjtu.constants.AuthenticationConstants;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.util.Date;

/**
 * nerine
 * 2/2/2020
 */
@Getter
@Setter
@ToString
public class UserAccountVo {
    /** pk */
    private String idUserAccount;
    /** 账号id */
    private String userId;
    /** 账号中文名 */
    private String userName;
    private String password;
    /** 对应的子系统id */
    private ClientInfoVo clientInfo;
    /** 角色权限 */
    private AuthenticationConstants.RoleType role;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createdDate;

    public boolean isAdmin() {
        return this.role != null && this.role == AuthenticationConstants.RoleType.ADMIN;
    }
    public boolean isNotAdmin() {
        return !isAdmin();
    }
    public boolean isOperator() {
        return this.role != null &&
                (this.role == AuthenticationConstants.RoleType.ADMIN
                        || this.role == AuthenticationConstants.RoleType.OPERATOR);
    }
    public boolean isNotOperator() {
        return !isOperator();
    }
}
